package com.example.demo.service.impl;

import com.example.demo.dao.Short1Dao;
import com.example.demo.entity.Short1;
import com.example.demo.service.Short1Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Short1)表服务实现类
 *
 * @author hjl
 * @since 2020-11-30 19:49:01
 */
@Service("short1Service")
public class Short1ServiceImpl implements Short1Service {
    @Resource
    private Short1Dao short1Dao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Short1 queryById(Integer id) {
        return this.short1Dao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Short1> queryAllByLimit(int offset, int limit) {
        return this.short1Dao.queryAllByLimit(offset, limit);
    }

    /**
     * 根据实例对象查询
     *
     * @param short1 实例对象
     * @return 对象列表
     */
    @Override
    public List<Short1> queryByExample(Short1 short1) {
        return this.short1Dao.queryAll(short1);
    }

    /**
     * 新增数据
     *
     * @param short1 实例对象
     * @return 实例对象
     */
    @Override
    public Short1 insert(Short1 short1) {
        this.short1Dao.insert(short1);
        return short1;
    }

    @Override
    public List insertList(List<Short1> list) {
        this.short1Dao.insertList(list);
        return list;
    }

    /**
     * 修改数据
     *
     * @param short1 实例对象
     * @return 实例对象
     */
    @Override
    public Short1 update(Short1 short1) {
        this.short1Dao.update(short1);
        return this.queryById(short1.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.short1Dao.deleteById(id) > 0;
    }
}